//
//  UseCouponViewController.m
//  FaceTo
//
//  Created by 程邦明 on 2017/8/11.
//  Copyright © 2017年 chengbangming. All rights reserved.
//

#import "UseCouponViewController.h"
#import "UseImageTableViewCell.h"
#import "UseProNameTableViewCell.h"
#import "UseRuleTableViewCell.h"
#import "PayViewController.h"
@interface UseCouponViewController ()<UITableViewDelegate,UITableViewDataSource>
{
    
}
@property (nonatomic ,strong) UITableView * tableView;
@property (nonatomic ,strong) UIButton * useBtn;

@end

@implementation UseCouponViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self initUI];
}
- (void)initUI{
    _tableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, kSCREEN_WIDTH, kSCREEN_HEIGHT) style:UITableViewStylePlain];
    _tableView.delegate = self;
    _tableView.dataSource = self;
    _tableView.tableFooterView = [[UIView alloc] initWithFrame:CGRectZero];
    [self.view addSubview:_tableView];
    
    _useBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [_useBtn setTitle:@"使用优惠券" forState:UIControlStateNormal];
    [_useBtn setTitleColor:Color(51, 51, 51) forState:UIControlStateNormal];
    [_useBtn setBackgroundColor:Color(251, 214, 70)];
    _useBtn.titleLabel.font = [UIFont systemFontOfSize:15];
    _useBtn.layer.masksToBounds = YES;
    [_useBtn addTarget:self action:@selector(UseCou) forControlEvents:UIControlEventTouchUpInside];
    _useBtn.layer.cornerRadius = 8;
    _useBtn.frame = CGRectMake(12, kSCREEN_HEIGHT-60, kSCREEN_WIDTH-24, 50);
    [self.view addSubview:_useBtn];
    
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 3;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    if(indexPath.row == 0){
        static NSString * identifier=@"cellIde1";
        UseImageTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier];
        if (cell == nil) {
            cell = [[UseImageTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier];
        }
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        return cell;
    }else if (indexPath.row == 1){
        static NSString * identifier=@"cellIde2";
        UseProNameTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier];
        if (cell == nil) {
            cell = [[UseProNameTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier];
        }
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        return cell;
    }else{
        static NSString * identifier=@"cellIde3";
        UseRuleTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier];
        if (cell == nil) {
            cell = [[UseRuleTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier];
        }
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        return cell;
    }
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    if(indexPath.row == 0){
        return 400;
    }else if (indexPath.row == 1){
        return 80;
    }else{
        return 90;
    }
}
- (void)UseCou{
    PayViewController * vc = [[PayViewController alloc]init];
    [self.navigationController pushViewController:vc animated:YES];
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
